package com.iursp.mapper.user;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.iursp.domain.model.role.Role;
import com.iursp.domain.model.user.User;

import tk.mybatis.mapper.common.BaseMapper;

@Mapper 
public interface UserMapper extends BaseMapper<User>{

	@Update("update common_user set deleted=true where refid=#{id}")
	int delUserById(String id);

	@Select("select * from common_user where user_name=#{username} or telephone=#{telephone}")
	User selectUserByNameOrMobile(@Param("username")String username,@Param("telephone")String telphone);

	@Select("SELECT * FROM common_user AS u LEFT JOIN auth_user_role r ON r.user_refid = u.refid "
			+ "WHERE r.role_row_key = #{roleRowKey} AND r.active = TRUE AND r.deleted = FALSE AND u.deleted = FALSE ")
	List<User> getRoleUserList(Role role);

}